home *** CD-ROM | disk | FTP | other *** search
- global allTogether, fit, piecesParts, allPieces, newConnect, start, totalPieces, tolerance, stageWide, stageTall, puzzleLayout, previewSprite, edgeMembers, showEdges, currentPuzzle, canRotate, isShockmachine, difficulty
-
- on writeFile
- filePath = the moviePath & "demoSaveFile"
- fileText = member("user message").text
- if fileText = EMPTY then
- alert("Please enter a text message to save")
- exit
- end if
- fileIOInstance = xtra("FileIO").new()
- if not fileIOInstance.objectp then
- alert("File IO Xtra missing")
- exit
- end if
- fileIOInstance.createFile(filePath)
- case fileIOInstance.status() of
- 0:
- nothing()
- (-122):
- fileIOInstance.openFile(filePath, 0)
- delete(fileIOInstance)
- fileIOInstance.createFile(filePath)
- otherwise:
- alert("Error: " & fileIOInstance.error(fileIOInstance.status()))
- exit
- end case
- fileIOInstance.openFile(filePath, 0)
- fileIOInstance.writeString(fileText)
- fileIOInstance.closeFile()
- end
-
- on readFile
- filePath = the moviePath & "demoSaveFile"
- fileIOInstance = xtra("FileIO").new()
- if not fileIOInstance.objectp then
- alert("File IO Xtra missing")
- exit
- end if
- fileIOInstance.openFile(filePath, 0)
- if fileIOInstance.status() = 0 then
- fileText = fileIOInstance.readFile()
- fileIOInstance.closeFile()
- member("file contents").text = fileText
- else
- member("file contents").text = "Error: " & fileIOInstance.error(fileIOInstance.status())
- end if
- end
-
- on getSystemFolder
- put getOSDirectory()
- end
-
- on savePuzzleFileIO
- cursor(4)
- beep()
- the itemDelimiter = "."
- preview = [:]
- addProp(preview, sprite(previewSprite).visible, the rect of sprite previewSprite)
- addProp(preview, sprite(previewSprite - 1).visible, the rect of sprite (previewSprite - 1))
- addProp(preview, sprite(previewSprite - 2).visible, the rect of sprite (previewSprite - 2))
- addProp(preview, sprite(previewSprite - 3).visible, the rect of sprite (previewSprite - 3))
- addProp(preview, sprite(previewSprite - 4).visible, the rect of sprite (previewSprite - 4))
- addProp(preview, sprite(previewSprite - 5).visible, the rect of sprite (previewSprite - 5))
- pieces = [:]
- thisSprite = 1
- repeat while thisSprite <= totalPieces
- addProp(pieces, (the member of sprite (thisSprite + 1)).number, the loc of sprite (thisSprite + 1))
- thisSprite = 1 + thisSprite
- end repeat
- rotations = []
- aPiece = 1
- repeat while aPiece <= totalPieces
- add(rotations, sprite(aPiece + 1).rotation)
- aPiece = 1 + aPiece
- end repeat
- timeSoFar = the ticks - start
- setupInfo = allTogether & TAB & fit & TAB & piecesParts & TAB & allPieces & TAB & totalPieces & TAB & preview & TAB & pieces & TAB & rotations & TAB & timeSoFar & TAB & canRotate & TAB & difficulty
- writePuzzleFile(getOSDirectory() & currentPuzzle & ".txt", setupInfo)
- cursor(0)
- end
-
- on writePuzzleFile puzzFilePath, setupInfo
- put puzzFilePath
- filePath = puzzFilePath
- fileText = setupInfo
- fileIOInstance = xtra("FileIO").new()
- if not fileIOInstance.objectp then
- alert("File IO Xtra missing")
- exit
- end if
- fileIOInstance.createFile(filePath)
- case fileIOInstance.status() of
- 0:
- nothing()
- (-122):
- fileIOInstance.openFile(filePath, 0)
- delete(fileIOInstance)
- fileIOInstance.createFile(filePath)
- otherwise:
- alert("Error: " & fileIOInstance.error(fileIOInstance.status()))
- exit
- end case
- fileIOInstance.openFile(filePath, 0)
- fileIOInstance.writeString(fileText)
- fileIOInstance.closeFile()
- end
-
- on getPuzzleFileIO puzzFilePath
- filePath = puzzFilePath
- fileIOInstance = xtra("FileIO").new()
- if not fileIOInstance.objectp then
- alert("File IO Xtra missing")
- exit
- end if
- fileIOInstance.openFile(filePath, 0)
- if fileIOInstance.status() = 0 then
- fileText = fileIOInstance.readFile()
- fileIOInstance.closeFile()
- return fileText
- else
- return VOID
- end if
- end
-
- on deletePuzzleProgress
- filePath = getOSDirectory() & currentPuzzle & ".txt"
- fileIOInstance = xtra("FileIO").new()
- if not fileIOInstance.objectp then
- alert("File IO Xtra missing")
- exit
- end if
- fileIOInstance.createFile(filePath)
- case fileIOInstance.status() of
- 0:
- fileIOInstance.openFile(filePath, 0)
- delete(fileIOInstance)
- (-122):
- fileIOInstance.openFile(filePath, 0)
- delete(fileIOInstance)
- otherwise:
- alert("Error: " & fileIOInstance.error(fileIOInstance.status()))
- exit
- end case
- fileIOInstance = 0
- end
-